﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace FitnessHelperDesktopClient
{
  /// <summary>
  /// Служит для отображения ценности порции продукта
  /// </summary>
  class FoodValueConverter : IMultiValueConverter
  {
    public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
    {
      if (values.Length != 2 ||
          values[0] == null || values[1] == null ||
          values[0] == DependencyProperty.UnsetValue ||
          values[1] == DependencyProperty.UnsetValue)
      {
        return null;
      }

      var amount = (double)values[0];
      var foodValue = (double)values[1];
      return (amount * foodValue).ToString();
    }

    public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
    {
      throw new NotImplementedException();
    }
  }
}
